/**
 * 
 */
package br.srv.full.virtual.entities.faces;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * 
 * @author Delfino
 */
@Entity
@DiscriminatorValue(value = "M")
@IdClass(PKFacesActionMethod.class)
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "membertype", "name", "facesManagedBean" }))
public class FacesActionMethod extends FacesMember implements FacesAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@ManyToOne(targetEntity = FacesManagedBean.class, fetch = FetchType.EAGER, optional = false)
	@JoinColumns( { @JoinColumn(name = "facesManagedBeanId", referencedColumnName = "id", insertable = true, updatable = true, nullable = true) })
	private FacesManagedBean facesManagedBean;

	public FacesActionMethod() {
		super();
	}

	public FacesActionMethod(FacesManagedBean p_fmBean, String p_name) {
		super(p_name);
		facesManagedBean = p_fmBean;

	}

	/**
	 * @return the facesManagedBean
	 */
	public FacesManagedBean getFacesManagedBean() {
		return facesManagedBean;
	}

	/**
	 * @param p_facesManagedBean
	 *            the facesManagedBean to set
	 */
	public void setFacesManagedBean(FacesManagedBean p_facesManagedBean) {
		facesManagedBean = p_facesManagedBean;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "#{" + getFacesManagedBean().toString() + "." + getName() + "}";
	}
}
